Skip to content

Origin Automated Actions#2854

Draft
sparrowDom wants to merge 66 commits intomasterfrom
sparrowDom/automated-actions-lite
Draft

Origin Automated Actions#2854
sparrowDom wants to merge 66 commits intomasterfrom
sparrowDom/automated-actions-lite

Conversation

@sparrowDom
Copy link
Copy Markdown
Member

@sparrowDom sparrowDom commented Mar 24, 2026

Summary

This PR introduces a cron runtime supervisor for the Docker deployment that:

  • keeps supercronic scheduling from JSON config
  • adds authenticated REST endpoints for manual action runs
  • exposes API endpoints to inspect configured actions and run status

AWS KMS Signer Usage

Cron/manual actions still execute existing Hardhat tasks, so signer behavior is unchanged and continues to use the repo signer selection logic:

  • If AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are present, the task path selects AWS KMS signing.
  • KMS signing uses DirectKmsTransactionSigner (purrikey) with the configured relayer key id and region.
  • Transactions are signed by KMS and submitted normally by the task flow.
  • Transaction hashes are emitted in task logs (utils/txLogger), so run-level tx IDs are visible in container logs/Loki.

Cronjobs Configured via JSON

Cron configuration is now JSON-first:

  • Source of truth: contracts/cron/cron-jobs.json
  • Job schema:
    • name (string)
    • schedule (5-field cron expression)
    • enabled (boolean)
    • command (string)
  • Startup rendering validates config and fails fast on:
    • invalid/malformed schema
    • duplicate names
    • invalid schedule shape
    • zero enabled jobs
  • Enabled jobs are rendered to /etc/cronjob (with # <name> comments) and started via supercronic.

Cronjobs Triggered via API

A lightweight Node HTTP server is started with the container runtime and runs alongside supercronic.

  • Auth:
    • Bearer token required for /api/v1/*
    • token env var: ACTION_API_BEARER_TOKEN (required)
  • Trigger endpoint:
    • POST /api/v1/actions/:name/runs
    • returns 202 Accepted with:
      • runId
      • action
      • status
      • statusUrl
      • startedAt
    • includes Location header pointing to run status URL
  • Execution model:
    • async execution (queued -> running -> succeeded|failed)
    • manual triggers are allowed even when enabled=false
    • parallel runs are allowed
    • bounded in-memory run history (default limit 500)

Cron Configuration / Run Status via API

  • GET /api/v1/actions
    • returns configured actions with name, schedule, enabled
  • GET /api/v1/runs/:runId
    • returns run lifecycle + completion metadata:
      • status
      • startedAt
      • finishedAt
      • exitCode
      • signal
  • GET /healthz (no auth)
    • runtime health including whether supercronic is running

Runtime Notes

  • Entrypoint now launches the supervisor (node /app/scripts/cron-supervisor.js).
  • Optional runtime envs:
    • HOST (default 0.0.0.0)
    • PORT (default 8080)
    • ACTION_RUN_HISTORY_LIMIT (default 500)
    • ACTION_WORKDIR (default /app)
  • Logs for a run are available in container stdout/stderr (and Loki), while API returns structured status/metadata.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.94%. Comparing base (10b029e) to head (ef16785).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2854      +/-   ##
==========================================
+ Coverage   49.21%   50.94%   +1.73%     
==========================================
  Files         112      112              
  Lines        4844     4844              
  Branches     1343     1343              
==========================================
+ Hits         2384     2468      +84     
+ Misses       2456     2372      -84     
  Partials        4        4              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@railway-app railway-app bot temporarily deployed to reasonable-success / production March 27, 2026 14:38 Inactive
sparrowDom and others added 19 commits March 27, 2026 16:55
- Add TypeScript, ESLint TS, and Prettier TS support to contracts/
- Create action() registration pattern for hardhat tasks with Winston logging
- Convert 13 Defender actions to self-registering TS hardhat tasks
- Add Loki transport for centralized logging
- Add healthcheck task for validation
- Fix ssv-scanner dependency (bloxapp → ssvlabs)
- Fix @lodestar/types ESM compatibility via ts-node skipProject
sparrowDom and others added 30 commits April 7, 2026 11:22
- Replace console logging with winston/Loki logger in supervisor
- Delete log-events.ts emit wrappers, inline structured logging in action.ts
- Extract HTTP API + run tracking into api.ts, slim supervisor to orchestrator
- Add action.start/action.success events to action framework
- Generate run_id (UUID) per action, remove AUTOMATON_RUN_ID env var
- Add real action.test.ts that exercises createActionHandler() with mock signer
- Delete stale test-action.ts, action-runner.test.ts, snapshot
…ion (#2876)

* Add shared Postgres nonce queue for cross-repo transaction serialization

Both origin-dollar and arm-oeth cron containers use the same KMS signer,
risking nonce collisions when transactions are sent concurrently. This adds
a Postgres-backed nonce lock that wraps the signer transparently via
SELECT ... FOR UPDATE, holding the row lock for the full tx lifecycle.

- nonceQueue.ts: withNonceLock + wrapWithNonceQueue signer wrapper
- action.ts: conditionally wraps signer when DATABASE_URL is set
- docker-compose.yml: adds postgres service for local dev
- cron-supervisor.ts: pool cleanup on shutdown
- Includes integration tests verifying lock serialization

* add comment

* add timeout mechanism

* add functionality to replace transaction with higher gas and rebroadcast transaction

* add github tests for the nonce locking mechanism

* add lifecycle tests

* fix lint

* add maximum gas price spending caps per chain

---------

Co-authored-by: Christopher Jacobs <apexearth@gmail.com>
…ow a flag to differentiate between Winston contextualized logs and old way of logs
…ed to all logs. Also fix issue where Grafana wouldn't receive most of emitted logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants